package com.ly.system.controller.question;

import com.ly.common.core.controller.BaseController;
import com.ly.common.core.domain.R;
import com.ly.common.core.domain.TableDataInfo;
import com.ly.system.domain.question.dto.QuestionAddDTO;
import com.ly.system.domain.question.dto.QuestionEditDTO;
import com.ly.system.domain.question.dto.QuestionQueryDTO;
import com.ly.system.domain.question.vo.QuestionDetialVO;
import com.ly.system.domain.question.vo.QuestionVO;
import com.ly.system.service.question.IQuestionService;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.Getter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/question")
@Tag(name="题目管理接口")
public class QuestionController extends BaseController {
    @Autowired
    private IQuestionService questionService;
    //question/list
    @GetMapping("/list")
    public TableDataInfo list(QuestionQueryDTO questionQueryDTO){
        return getTableDataInfo(questionService.list(questionQueryDTO));
    }

    //question/add
    @PostMapping("/add")
    public R<Void> add(@RequestBody QuestionAddDTO questionAddDTO){
        return toR(questionService.add(questionAddDTO));
    }


    //question/detail
    @GetMapping("/detail")
    public R<QuestionDetialVO> detail(Long questionId){
        return R.ok(questionService.detail(questionId));
    }

    //question/edit
    @PutMapping("/edit")
    public R<Void> edit(@RequestBody QuestionEditDTO questionEditDTO){
         return  toR(questionService.edit(questionEditDTO));
    }

    @DeleteMapping("/delete")
    public R<Void> delete(Long questionId){
        return toR(questionService.delete(questionId));
    }

}
